package GtfsField;

# A GTFS field/column definition, for generation ORM scaffolding.
$GtfsField::VERSION = 0.01;

use strict; 
use warnings;

### OO METHODS
sub new {
	my $class = shift;

  my (%self) = @_;	

	$self{name} = "UNKNOWN'" unless $self{name};
	$self{column} = $self{name} unless $self{column};
	$self{type} = "String'" unless $self{type};
	$self{type} = "String'" unless $self{type};
	$self{db_type} = "UNKNOWN" unless $self{db_type};
	$self{required} = 0 unless $self{required};
	$self{description} = 0 unless $self{description};

	#### cast the spell
  return bless(\%self, $class);
}

sub name {
    my $self = shift;
    if(scalar @_ > 0) {
      $self->{name}  = shift;
    } 
    return $self->{name};
}
sub type {
    my $self = shift;
    if(scalar @_ > 0) {
      $self->{type}  = shift;
    } 
    return $self->{type};
}


sub column {
    my $self = shift;
    if(scalar @_ > 0) {
      $self->{column}  = shift;
    } 
    return $self->{column};
}
sub dbType {
    my $self = shift;
    if(scalar @_ > 0) {
      $self->{db_type}  = shift;
    } 
    return $self->{db_type};
}

sub required {
    my $self = shift;
    if(scalar @_ > 0) {
      $self->{required}  = shift;
    } 
    return $self->{required};
}

sub description {
    my $self = shift;
    if(scalar @_ > 0) {
      $self->{description}  = shift;
    } 
    return $self->{description};
}

sub getter {
    my $self = shift;
    if("Boolean" eq $self->type()) {
      return "is" . ucfirst($self->name());
    } else {
      return "get" . ucfirst($self->name());
    }
}

sub setter {
    my $self = shift;
    return "set" . ucfirst($self->name());
}

1;


__END__


